<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- 分页 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<c:url value='/jquery/jquery.js'/>"></script>
<link  rel="stylesheet"  href="/ajaxweb_mybatis/a.css">

<script type="text/javascript">

 function removeCustomer(cid) {
	
	 if(confirm("确认删除")){
		 //请求Servle删除方法
		 window.location.href="<c:url value='/CustomerServlet?method=removeCustomer&cid='/>"+cid;
	 }
} 

</script>
</head>

<body>

    <form action="<c:url value='/CustomerServlet'/>">
    <!-- 隐藏字段 -->
    <input type="hidden" name="method" value="getCustomerByPage"/>
               <%-- 编号 ：<input type="text" name="cid" value="${customer.cid}"/><br/> --%>
	      姓名：<input type="text" name="cname" value="${customer.cname}"/><br/>
	      性别：<select name="gender"><br/>
            
	         <option value="" <c:if test="${empty customer.gender }">selected="selected"</c:if>>请选择</option><br/>
	         
	         <option value="男"  
	         
	         <c:if test="${customer.gender eq '男'}">selected="selected"</c:if>>男
	         
	         </option>
	         
	         <option value="女"
	         
	         <c:if test="${customer.gender eq '女'}">selected="selected"</c:if>>女
	         
	         </option>
         
      </select><br/>
      
	       电话：<input type="text" name="cellphone" value="${customer.cellphone}"/><br/>
	       邮箱：<input type="text" name="email" value="${customer.email}"/><br/>
	       生日：<input type="text" name="birthday" value="${customer.birthday}"/><br/>
	    <input type="submit" value="查询"/>  
    </form>
    <a href="/ajaxweb_mybatis/insert.jsp">新增</a><br/>
	<table>
	
		<tr>
			<td>姓名</td>
			<td>性别</td>
			<td>出生日期</td>
			<td>电话</td>
			<td>邮箱</td>
			<td>描述信息</td>
			<td>操作</td>
		</tr>

		<c:forEach var="customer" items="${pageBean.beanList}">
			<tr>
				<td>${customer.cname}</td>
				<td>${customer.gender}</td>
				<td>${customer.birthday}</td>
				<td>${customer.cellphone}</td>
				<td>${customer.email}</td>
				<td>${customer.description}</td>
				<td>
				     <a href="<c:url value=
				     '/CustomerServlet?method=getCustomerByCid&cid=${customer.cid}'/>">修改</a>
				     <a href="javascript:removeCustomer('${customer.cid}')">删除</a>
				     <%-- <a href="<c:url value=
				     '/CustomerServlet?method=getCustomerUserByCid&cid=${customer.cid}'/>">新增</a> --%>
				</td>
			</tr>
		</c:forEach>
	</table>
	<div id="page">
	    
	      
	      <c:if test="${pageBean.pageIndex>1}">
	      
	      <a href="${pageBean.url}&pageIndex=${pageBean.pageIndex-1}">上一页</a>
	      
	      </c:if>
	      
	    <!--分页显示页码  -->
	    <c:forEach var="i" begin="${pageBean.pageBegin}" end="${pageBean.pageEnd}" step="1">
	    
	    <c:choose>
	    
	     <c:when test="${pageBean.pageIndex==i}">
	      [${i}]
	     </c:when>
	     
	     <c:otherwise>
	      <a href="${pageBean.url}&pageIndex=${i}">${i}</a>
	     </c:otherwise>
	     
	    </c:choose>
	    
	    </c:forEach>
	     <c:if test="${pageBean.pageIndex<pageBean.totalPage}">
	     
	      <a href="${pageBean.url}&pageIndex=${pageBean.pageIndex+1}">下一页</a><br/>
	     </c:if>
	    共${pageBean.totalPage}页,第${pageBean.pageIndex}页
	</div>
</body>
</html>